package cn.tedu.project.oa.assessProject.controller;

import cn.tedu.project.oa.assessProject.pojo.entity.Target;
import cn.tedu.project.oa.assessProject.service.ITargetService;
import cn.tedu.project.oa.base.response.JsonResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/oa/assess/target")
@Api(tags = "14.考核指标")
public class TargetController {
    @Autowired
    private ITargetService targetService;

    /**
     * 查询考核指标列表
     */
    @GetMapping("/list")
    public JsonResult list(Target target)
    {
        List<Target> list = targetService.selectTargetList(target);
        return JsonResult.ok(list);
    }

//    /**
//     * 导出考核指标列表
//     */
//    @Log(title = "考核指标", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Target target)
//    {
//        List<Target> list = targetService.selectTargetList(target);
//        ExcelUtil<Target> util = new ExcelUtil<Target>(Target.class);
//        util.exportExcel(response, list, "考核指标数据");
//    }

    /**
     * 获取考核指标详细信息
     */
    @GetMapping(value = "/{id}")
    public JsonResult getInfo(@PathVariable("id") Long id)
    {
        return JsonResult.ok(targetService.selectTargetById(id));
    }

    /**
     * 新增考核指标
     */
    @PostMapping
    public JsonResult add(@RequestBody Target target)
    {
        return JsonResult.ok(targetService.insertTarget(target));
    }

    /**
     * 修改考核指标
     */
    @PutMapping
    public JsonResult edit(@RequestBody Target target)
    {
        return JsonResult.ok(targetService.updateTarget(target));
    }

    /**
     * 删除考核指标
     */
    @DeleteMapping("/{ids}")
    public JsonResult remove(@PathVariable Long[] ids)
    {
        return JsonResult.ok(targetService.deleteTargetByIds(ids));
    }
}
